//User模块下的vuex
import {
    reqUserAddressList, reqTradeInfo
} from "@/api";



const state = {
    userAddressList: [],
    tradeInfo: {},

};

const mutations = {
    //保存Token
    GETUSERADDRESSLIST(state, userAddressList) {
        state.userAddressList = userAddressList;
    },
    GETTRADEINFO(state, tradeInfo) {
        state.tradeInfo = tradeInfo;
    }

};

const actions = {
    //获取用户地址信息
    async getUserAddressList({ commit }) {
        let result = await reqUserAddressList();
        if (result.code == 200) {
            commit('GETUSERADDRESSLIST', result.data);
        } else {
            return Promise.reject(new Error('faile'))
        }
    },
    //获取用户的交易信息
    async getTradeInfo({ commit }) {
        let result = await reqTradeInfo();
        if (result.code == 200) {
            commit('GETTRADEINFO', result.data);
        } else {
            return Promise.reject(new Error('faile'))
        }
    },



};

const getters = {

};

export default { state, mutations, actions, getters };
